package com.lds.config.center.remote.client.server.impl;


import com.lds.config.center.common.model.namespace.request.NamespaceBaseListRequest;
import com.lds.config.center.common.model.namespace.response.NamespaceBaseListResponse;
import com.lds.config.center.remote.client.properties.ConfigCenterRemoteClientProperties;
import com.lds.config.center.remote.client.server.NamespaceRemoteClient;
import com.lds.management.center.common.model.dto.ResultDTO;
import com.lds.management.center.common.util.RestUtil;
import org.springframework.core.ParameterizedTypeReference;

public class NamespaceRemoteClientImpl implements NamespaceRemoteClient {
    private final ConfigCenterRemoteClientProperties properties;
    
    public NamespaceRemoteClientImpl(ConfigCenterRemoteClientProperties properties) {
        this.properties = properties;
    }
    
    @Override
    public ResultDTO<NamespaceBaseListResponse> listNamespace(NamespaceBaseListRequest request) {
        String url = properties.getAddress() + "/api/common/namespace/list";
        return RestUtil.post(url, request, new ParameterizedTypeReference<ResultDTO<NamespaceBaseListResponse>>() {});
    }
}
